@(loginForm: Form[(String,String)], errorMsg: Option[String] = None)(implicit request: RequestHeader, messages: Messages, env:securesocial.core.RuntimeEnvironment)

@import securesocial.core.providers.UsernamePasswordProvider.UsernamePassword

@securesocial.views.html.main(Messages("securesocial.login.title")) {
    <div class="page-header">
        <h1>@Messages("securesocial.login.title")</h1>
    </div>

    @errorMsg.map { msg =>
        <div class="alert alert-error">
            @Messages(msg)
        </div>
    }

    @request.flash.get("success").map { msg =>
        <div class="alert alert-info">
            @msg
        </div>
    }

    @request.flash.get("error").map { msg =>
        <div class="alert alert-error">
            @msg
        </div>
    }


@defining( env.providers.values.filter( _.id != UsernamePassword) ) { externalProviders =>

        @if( externalProviders.size > 0 ) {
            <div class="clearfix">
                <p>@Messages("securesocial.login.instructions")</p>
                <p>
                    @for(p <- externalProviders) {
                        @securesocial.views.html.provider(p.id)
                    }
                </p>
            </div>
        }

        @env.providers.get(UsernamePassword).map { up =>
            <div class="clearfix">
                @if( externalProviders.size > 0 ) {
                    <p>@Messages("securesocial.login.useEmailAndPassword")</p>
                } else {
                    <p>@Messages("securesocial.login.useEmailAndPasswordOnly")</p>
                }

               @securesocial.views.html.provider("userpass", Some(loginForm))
            </div>
        }
    }
}